<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>学生管理</title>
	<meta name="decorator" content="default"/>
	<%
		Object optObj = request.getAttribute("opt");
		String opt = null;
		if(optObj!=null){
			opt = (String)optObj;
		}
		if(opt!=null && opt.equals("detail")){ 
	%>
	 <script type="text/javascript">
		$(document).ready(function() {
			$(this).find("input").each(function() {
				$(this).attr("disabled", "disabled");
				}); 
			$(this).find("select").each(function() {
				$(this).attr("disabled", "disabled");
				});
		});
	</script>
	 <%
	 	}else{
	 %>
	<script type="text/javascript">
		$(document).ready(function() {
			//$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
	</script>
	<%}%>
	<style>
	.imgsty{
		isplay: inline-block; width:200px;height:100px;padding: 5px;
	}
	</style>
	<script type="text/javascript">
		function ajaxFileUpload(ipt,imgStr) {
		    //图片格式验证
		    var x = ipt;
		    if (!x || !x.value) return;
		    var patn = /\.jpg$|\.jpeg$|\.png$|\.gif$/i;
		    if (!patn.test(x.value)) {
		        alert("您选择的似乎不是图像文件。");
		        x.value = "";
		        return;
		    }

		    var elementIds = [ipt]; //flag为id、name属性名
		    var hiddenIpt = ipt.previousElementSibling;
		    $.ajaxFileUpload({
		        url: '${ctx}/pic/img/upload', 
		        type: 'post',
		        secureuri: false, //一般设置为false
		        fileElementId: ipt.id, // 上传文件的id、name属性名
		        dataType: 'json', //返回值类型，一般设置为json、application/json
		        elementIds: elementIds, //传递参数到服务器
		        success: function (data, status) {
		            if (data.status != 200) {
		                alert("文件太大，请上传不大于5M的文件！");
		                return;
		            }else {
		                //这里为上传并做一下请求显示处理，返回的data是对应上传的文件名
		            	document.getElementById(imgStr).src = data.data
		            	hiddenIpt.value = data.data
		            }
		        },
		        error: function (data, status, e) {
		            alert(e);
		        }
		    });
		    //return false;
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/student/bizStudent/">学生列表</a></li>
		<li class="active"><a href="${ctx}/student/bizStudent/form?id=${bizStudent.id}">学生<shiro:hasPermission name="student:bizStudent:edit">${not empty bizStudent.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="student:bizStudent:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="bizStudent" action="${ctx}/student/bizStudent/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>		
		
		<fieldset>
			<legend>学生信息</legend>
			<table class="table-form">
				<tr>
					<td class="tit" rowspan="2">照片信息</td>
					<td class="tit">头像</td>
					<td>
						<img id="picHeadImg" alt="头像" class="imgsty" src="${not empty bizStudent.picHead?bizStudent.picHead:'/static/img/timg.jpg'}" /><br/>
						<form:hidden path="picHead" class="input-middle"/>
						<input type="file" name="picHeadIbg" id="picHeadIbg" onchange="ajaxFileUpload(this,'picHeadImg')" class="input-middle"/>
					<td class="tit">全身照</td>
					<td>
						<img id="picBodyImg" alt="全身照" style="display: inline-block; width:200px;height:100px;" src="${not empty bizStudent.picBody?bizStudent.picBody:'/static/img/timg.jpg'}" /><br/>
						<form:hidden path="picBody" class="input-middle"/>
						<input type="file" name="picBodyIbg" id="picBodyIbg" onchange="ajaxFileUpload(this,'picBodyImg')" class="input-middle"/>
					</td>
					<td class="tit">素颜照</td>
					<td>
						<img id="picNomakeImg" alt="素颜照" style="display: inline-block; width:200px;height:100px;" src="${not empty bizStudent.picNomake?bizStudent.picNomake:'/static/img/timg.jpg'}" /><br/>
						<form:hidden path="picNomake" class="input-middle"/>
						<input type="file" name="picNomakeIbg" id="picNomakeIbg" onchange="ajaxFileUpload(this,'picNomakeImg')" class="input-middle"/>
					</td>
				</tr>
				<tr>
					<td class="tit">生活照</td>
					<td>
						<img id="picLifeImg" alt="头像" style="display: inline-block; width:200px;height:100px;" src="${not empty bizStudent.picLife?bizStudent.picLife:'/static/img/timg.jpg'}" /><br/>
						<form:hidden path="picLife" class="input-middle"/>
						<input type="file" name="picLifeIbg" id="picLifeIbg" onchange="ajaxFileUpload(this,'picLifeImg')" class="input-middle"/>
					</td>
					<td class="tit"></td>
					<td></td>
					<td class="tit"></td>
					<td></td>
				</tr>
				<tr>
					<td class="tit" rowspan="3">基本信息</td>
					<td class="tit">学生姓名：</td>
					<td><form:input path="stuName" htmlEscape="false" maxlength="255" class="input-xlarge required"/>
						<span class="help-inline"><font color="red">*</font> </span></td>
					<td class="tit">手机号</td>
					<td><form:input path="telNo" htmlEscape="false" maxlength="255" class="input-xlarge required"/>
						<span class="help-inline"><font color="red">*</font> </span></td>
					<td class="tit">出生日期</td>
					<td><input name="birthday" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate "
					value="<fmt:formatDate value="${bizStudent.birthday}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/></td>
				</tr>
				<tr>
					<td class="tit">身高</td>
					<td><form:input path="stuHeight" htmlEscape="false" class="input-xlarge "/></td>
					<td class="tit">体重</td>
					<td><form:input path="stuWeight" htmlEscape="false" class="input-xlarge "/></td>
					<td class="tit"></td>
					<td></td>
				</tr>
				<tr>
					<td class="tit">性别</td>
					<td><form:select path="gender" class="input-xlarge required">
							<form:option value="" label=""/>
							<form:options items="${fns:getDictList('gender')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
						</form:select>
						<span class="help-inline"><font color="red">*</font> </span></td>
					<td class="tit">民族</td>
					<td><form:select path="stuNation" class="input-xlarge ">
							<form:option value="" label=""/>
							<form:options items="${fns:getDictList('nation')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
						</form:select></td>
					<td class="tit">籍贯</td>
					<td><form:input path="nativePalce" htmlEscape="false" maxlength="255" class="input-xlarge "/></td>
				</tr>
				<tr>
					<td class="tit" rowspan="2">学校信息</td>
					<td class="tit">学校</td>
					<td><form:select path="schId" class="input-xlarge ">
							<form:option value="" label=""/>
							<form:options items="${fns:getDictList('sch')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
						</form:select></td>
					<td class="tit">学科</td>
					<td><form:input path="subjectId" htmlEscape="false" maxlength="255" class="input-xlarge "/></td>
					<td class="tit">院系</td>
					<td><form:input path="scFaculty" htmlEscape="false" maxlength="255" class="input-xlarge "/></td>
					
				</tr>
				<tr>
					<td class="tit">高中名称</td>
					<td><form:input path="highSchName" htmlEscape="false" maxlength="255" class="input-xlarge "/></td>
					<td class="tit">初中</td>
					<td><form:input path="midSchName" htmlEscape="false" maxlength="255" class="input-xlarge "/></td>
					<td class="tit">现居住地</td>
					<td><form:select path="provinceId" class="input-small ">
							<form:option value="" label=""/>
							<form:options items="${fns:getProvinceList()}" itemLabel="provinceName" itemValue="id" htmlEscape="false"/>
						</form:select>
						<form:select path="cityId" class="input-small">
							<form:option value="" label=""/>
							<form:options items="${fns:getCityList()}" itemLabel="cityName" itemValue="id" htmlEscape="false"/>
						</form:select><form:input path="domicile" htmlEscape="false" maxlength="255"  class="input-small"/></td>
				</tr>

			</table>
		</fieldset>
		
		
		<div class="form-actions">
			<shiro:hasPermission name="student:bizStudent:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>